package schoolDemo3;

public class App4_12 {
    public static void main(String[] args) {
        final int Max=100;//定义素数的范围是100
        int j,k,n;
        System.out.println("2~"+Max+"的所有素数为：");
        System.out.print("2\t");
        n=1;
        k=3;
        do {
            j=3;
            while (j<Math.sqrt(k)&&(k%j!=0))
                j++;
            if(j>Math.sqrt(k))
            {
                System.out.print(k+"\t");
                n++;
                if(n%10==0)
                    System.out.println();
            }
            k=k+2;
        }while (k<Max);
        System.out.println("\n共有"+n+"个素数");
    }
}
